import request from '@/utils/request'

/**
 * 获取部门信息
 * @returns
 */
export const getDepartmentsApi = () => {
  return request({
    url: '/company/department'
  })
}

/**
 *根据ID删除部门
 * @param {*} id 部门ID
 * @returns
 */
export const delDepartmentApi = id => {
  return request({
    method: 'DELETE',
    url: `/company/department/${id}`
  })
}

/**
 * 新增部门
 * @param {*} data form里各键值对加pid
 * @returns
 */
export const addDepartmentsApi = data => {
  return request({
    method: 'POST',
    url: '/company/department',
    data
  })
}

/**
 * 根据ID查询部门详情
 * @param {*} id 部门Id
 * @returns
 */
export function getDetailDepartApi(id) {
  return request({
    url: `/company/department/${id}`
  })
}

// 根据ID修改部门详情

export function updateDepartmentsApi(data) {
  return request({
    method: 'PUT',
    url: `/company/department/${data.id}`,
    data
  })
}
